// pages/classify/classify.js
const app = getApp();
import http from "../../utils/http";
import util from "../../utils/util";
Page({
	data: {
		cate: [
			{ id: "1", label: "分类" },
			{ id: "2", label: "卡项专区" },
			{ id: "3", label: "团课专区" },
			{ id: "4", label: "品牌介绍" },
		],
		active: 0,
	},

	toDetail(e) {
		console.log(e);
		// const item = e.currentTarget.dataset.item;

		util.skip("/service/cardServiceDetail/cardServiceDetail?id=" + 1);
	},
	getInfo() {
		http
			.get(
				"skill/skillinfo",
				{
					id: this.data.skill_id,
					lng: app.globalData.address.lng,
					lat: app.globalData.address.lat,
				},
				true
			)
			.then((res) => {
				let eduArr = [
					"小学文化",
					"初中",
					"高中",
					"大专",
					"本科",
					"硕士",
					"博士",
				];
				res.data.edu = eduArr[res.data.edu];
				res.data.images = res.data.images ? res.data.images : [];
				res.data.images.unshift(res.data.image);
				this.setData({
					info: res.data,
				});
			});
		http
			.get("comment/getlist", {
				skill_id: this.data.skill_id,
			})
			.then((res) => {
				this.setData({
					list: res.data,
				});
			});
		http
			.get("comment/totalcomment", {
				skill_id: this.data.skill_id,
				type: "skill",
			})
			.then((res) => {
				this.setData({
					num: res.data,
				});
			});
	},

	onLoad() {
		this.getInfo();
	},
	cateTap(e) {
		util.skip(
			"/service/catelist/catelist?two_category_id=" +
				e.currentTarget.dataset.item.id +
				"&name=" +
				e.currentTarget.dataset.item.label
		);
	},
	getInfo() {
		http.post("category/getlist", { type: "all" }, true).then((res) => {
			this.setData({
				cate: res.data,
			});
		});
	},
	change(e) {
		this.setData({
			active: e.currentTarget.dataset.index,
		});
	},

	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage() {
		return {};
	},
});
